all files / bottomNav/ bottomNavItem.vue

45% Statements 9/20
26.67% Branches 4/15
14.29% Functions 1/7
28.57% Lines 4/14
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                  1× 1× 1×                                                                                                          
//
//
//
//
//
//
//
//
 
import abstractButton from '../internal/abstractButton'
import icon from '../icon'
import {isNotNull} from '../utils'
export default {
  name: 'mu-bottom-nav-item',
  props: {
    icon: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    href: {
      type: String
    },
    value: {}
  },
  data () {
    return {
      bottomNav: null
    }
  },
  created () {
    this.isBottomNavItem = true
  },
  computed: {
    active () {
      return this.bottomNav && isNotNull(this.value) && this.bottomNav.value === this.value
    },
    shift () {
      return this.bottomNav && this.bottomNav.shift
    }
  },
  methods: {
    handleClick () {
      if (this.bottomNav && this.bottomNav.handleItemClick) this.bottomNav.handleItemClick(this.value)
    }
  },
  mounted () {
    let children = this.$parent.$children
    for (let i = 0; i < children.length; i++) {
      if (children[i].$el === this.$el) {
        this.index = i
        break
      }
    }
  },
  components: {
    'abstract-button': abstractButton,
    icon
  }
}